package avans.di15.groep1;

import nl.webservices.www.soap.WebservicesNlBindingStub;
import nl.webservices.www.soap.WebservicesNlLocator;

public class Afstanden {

	/**
	 * @param args
	 */
	public static String geefAfstand(String postCodeFrom, String postCodeTo){
		System.out.println(postCodeFrom + " " + postCodeTo);
		return getGegevens(postCodeFrom,postCodeTo) ;
		// getGegevens();
	}
	public static String getGegevens(String postCodeFrom, String postCodeTo){
		WebservicesNlLocator secServer = new WebservicesNlLocator();
		secServer.setWebservicesNlPortEndpointAddress(secServer.getWebservicesNlPortAddress());//getSecurityServerHttpPortAddress());
		WebservicesNlBindingStub stub = null;
		try
		{
		  stub = (WebservicesNlBindingStub) secServer.getWebservicesNlPort();
		  String token =stub.login("AvansHogeschool_User8", "Avans321");
		  int resultaat = stub.reactGeoLocationPostcodeDistance(token, postCodeFrom, postCodeTo);
		resultaat = Math.round(resultaat / 1000);
		  return ""+ resultaat;
		}	catch (Exception e)
			{
			    System.err.print(e);
			    return "error";
			   
			}
		
	}
		
	public static void main(String[] args) {
		
		
		System.out.println(  getGegevens("4455AT","4631ML"));
	}
	}


